package day18;

import java.util.Scanner;

public class demo2 {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        for(int i=0;i<n;i++){
            int x=in.nextInt();
            StringBuffer sb=new StringBuffer();
            for(int j=0;j<x;j++){
                sb.append(in.next().charAt(0));
            }
            if(sb.toString().equals(sb.reverse().toString())) System.out.println("Yes");
            else System.out.println("No");
        }


    }
}
